//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics.Contracts;
using System.Windows.Input;

namespace OpenLS.Spreadsheet.UI
{
    class ActionCommand: ICommand
    {
        private readonly Action<object> _action;

        public ActionCommand(Action<object> action)
        {
            Contract.Requires(action != null);
            _action = action;
        }
        #region ICommand Members

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            _action.Invoke(parameter); 
        }

        #endregion
    }
}